package cn.iocoder.yudao.module.xiaoBizHandler.dal.mysql.attach;

import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.xiaoBizHandler.controller.admin.attach.vo.AttachQueryReqVO;
import cn.iocoder.yudao.module.xiaoBizHandler.dal.dataobject.attach.AttachDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 附件Mapper
 */
@Mapper
public interface AttachMapper extends BaseMapper<AttachDO> {

    default List<AttachDO> selectList(AttachQueryReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AttachDO>()
                .eqIfPresent(AttachDO::getId, reqVO.getId())
                .likeIfPresent(AttachDO::getAttachName, reqVO.getAttachName())
                .eqIfPresent(AttachDO::getAttachSuffix, reqVO.getAttachSuffix())
                .eqIfPresent(AttachDO::getAttachOwnerId, reqVO.getAttachOwnerId())
                .eqIfPresent(AttachDO::getAttachPath, reqVO.getAttachPath())
                .eqIfPresent(AttachDO::getAttachType, reqVO.getAttachType())
                .eqIfPresent(AttachDO::getAttachSize, reqVO.getAttachSize())
                .betweenIfPresent(AttachDO::getAttachSize, reqVO.getBeginAttachSize(), reqVO.getEndAttachSize())
                .eqIfPresent(AttachDO::getReferId, reqVO.getReferId())
                .eqIfPresent(AttachDO::getRegionId, reqVO.getRegionId())
                .eqIfPresent(AttachDO::getLastTime, reqVO.getLastTime())
                .betweenIfPresent(AttachDO::getLastTime, reqVO.getBeginLastTime(), reqVO.getEndLastTime())
                .eqIfPresent(AttachDO::getNowYear, reqVO.getNowYear())
                .betweenIfPresent(AttachDO::getNowYear, reqVO.getBeginNowYear(), reqVO.getEndNowYear())
                .eqIfPresent(AttachDO::getIsCopy, reqVO.getIsCopy())
                .eqIfPresent(AttachDO::getWaterMark, reqVO.getWaterMark())
                .eqIfPresent(AttachDO::getRegionName, reqVO.getRegionName())
                .eqIfPresent(AttachDO::getMoveNewRegionId, reqVO.getMoveNewRegionId())
                .orderByDesc(AttachDO::getId));
    }

}
